AO3-6960 Admin post drafts and previews#5822
Conversation
pmonfort
left a comment
There was a problem hiding this comment.
Great work! The code looks good. Tested locally and the core flow works well. Left a few comments, mostly small things.
| end | ||
| @admin_posts = @admin_posts.order('created_at DESC').page(params[:page]) | ||
| @page_subtitle = t(".page_title") | ||
| @admin_posts = @admin_posts.posted.order(published_at: :desc).page(params[:page]) |
There was a problem hiding this comment.
This uses will_paginate, but drafts below uses pagy. Should this also use pagy for consistency?
| if @admin_post.save | ||
| flash[:notice] = ts("Admin Post was successfully created.") | ||
| redirect_to(@admin_post) | ||
| if params[:preview_button] |
There was a problem hiding this comment.
Should we validate that the post is valid before previewing? Something similar to what's done in update where @admin_post.valid? is checked before previewing the post.
| @admin_post = AdminPost.find(params[:id]) | ||
| authorize @admin_post | ||
|
|
||
| @admin_post.posted = true |
There was a problem hiding this comment.
Should we also check @admin_post&.translated_post&.draft? like we do in create and update to avoid potential bugs?
There was a problem hiding this comment.
I've added a validation to the model to prevent translations from being posted first, which should cover this and also prevent already published posts from turned into translations of a draft post.
There was a problem hiding this comment.
Great approach, thanks for taking care of that!
| <%= span_if_current t(".ao3_news"), admin_posts_path %> | ||
| </li> | ||
| <li> | ||
| <%= span_if_current t(".ao3_news_drafts"), drafts_admin_posts_path %> |
There was a problem hiding this comment.
The "AO3 News Drafts" link is shown without a permission check. The ticket says it should be visible to "any admin with a role listed in the AdminPostPolicy section." Should this be wrapped in <% if policy(AdminPost).can_draft? %> like the other links?
| <% end %> | ||
|
|
||
| <% if @preview_mode %> | ||
| <li><%= form.submit t(".actions.edit"), name: "edit_button" %> |
There was a problem hiding this comment.
Missing </li> closing tag here.
| @admin @comments | ||
| Feature: Admin Actions to Draft News | ||
| In order to post news items | ||
| As an an admin |
Issue
https://otwarchive.atlassian.net/browse/AO3-6960
Purpose
Allows admins to save unpublished (draft) admin posts and preview changes before publication.
Testing Instructions
Manual QA steps TBD.
Credit
marcus8448 (he/him)